#!/usr/bin/python
# -*- coding: utf-8 -*-
"""
Mikan SQLite データベース機能

Mikan Python Web Framework
"""

__author__ = "K.Sonohara"
__status__ = "develop"
__version__ = "0.0.0_8"
__date__    = "2013/03/03"
__license__ = 'LGPL'

# ------------------------------------------------------------
## インポート
# ------------------------------------------------------------
# Python
import sqlite3

# ESiPC
from esipc.resource.iniresource import ESiPCINIFileResourceBundle

# Mikan
from mikan.db.rdbdb import AbstractMikanRDBDB

# ------------------------------------------------------------
## 変数
# ------------------------------------------------------------
RESOURCE = ESiPCINIFileResourceBundle(__file__)

# ------------------------------------------------------------
## 関数
# ------------------------------------------------------------
def _(key, default, locale=None):
	try:
		return RESOURCE.getString(key, default, locale)
	except:
		return default

# ------------------------------------------------------------
## クラス
# ------------------------------------------------------------

# ------------------------------------------------------------
## Mikan SQLite DB クラス
#
class MikanSqliteDB(AbstractMikanRDBDB):
	def __init__(self,  request):
		super(MikanSqliteDB, self).__init__( request)

	def setup(self, config, section):
		self.logger.debug(config.get(section, "filename"))
		self.connect(config.get(section, "filename"))

	def connect(self, filename=None):
		f = filename
		if (f == None):
			f = ":memory:"
		self.setConnector(sqlite3.connect(f))

	def createSQLID(self, entity, attribute):
		return True

	def sqlLastID(self):
		return u"SELECT last_insert_rowid() id;"

#	def sqlAutoID(self):
#		return u"SELECT last_insert_rowid() id;"

# ------------------------------------------------------------
## メイン関数
# ------------------------------------------------------------
if __name__ == '__main__':
	pass

# ------------------------------------------------------------
